export default {
    namespaced: true ,
    state: {
        name: '',
        //右边顶部菜单
        menuRight: ["登录", "注册", "消息通知", "购物车（0）"],
        //保存登陆用户
        createName: {
            name: '',
            pwd: '',
        }
    },
    mutations: {
        // 用户登陆后更改头部meun数据渲染
        changeMenu(state,val){
            state.menuRight.splice(0,2,val)
            state.name = val
        },
        //创建一个用户并保存到本地
        createUser(state,val){
            for(const prop in state.createName){
                state.createName[prop] = val[prop]
            }
            localStorage.setItem(state.createName.name,state.createName.pwd)
        },
        reMenu(state){
            state.menuRight = ["登录", "注册", "消息通知", "购物车（0）"]
           
        },
        updateShoppingCartNum(state, val) {
            state.menuRight.splice(state.menuRight.length-1,1,`购物车（${val}）`)
        }
    }
}